#include "SFMLInclude.h"
#include "GeneralHelperFunctions.h"
#include "GraphicsFramework.h"
#include "Entity.h"

#ifdef _DEBUG
#include <iostream>
#endif

int main(int argc, char** argv)
{
	_OpenGLFramework *Game = new _OpenGLFramework("Window_Settings.cfg");
	Globals *TempGameGlobals = new Globals;
	GameGlobals = TempGameGlobals;

	GameGlobals->LoadTexturesFromList("Textures.list");

	Game->LoadGameEntities();

#ifdef _DEBUG
	//std::cout << "SFML is using OpenGL Version: " << App->getSettings().majorVersion << "." << App->getSettings().minorVersion << std::endl;
#endif
	bool IsInFocus = false;

	float LastTime = (float)clock(),
		  CurrentTime = (float)clock();

	while(Game->Running())
	{
		CurrentTime = (float) clock();
		float dt = (CurrentTime - LastTime)/1000.f;

		if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
			Game->SetRunning(false);

		Game->Update(dt);
		Game->Render();

		LastTime = CurrentTime;

	}
	delete GameGlobals;
	delete Game;
	//_CrtDumpMemoryLeaks();
#ifdef _DEBUG
	_CrtDumpMemoryLeaks();
	//char temp = 0;
	//std::cin >> temp;
#endif
	return 0;
}